/**
 * StudentQuestionController.java
 * Version 1.0.0
 * Created on 2018年9月14日
 *
 */
package com.yincheng.oes.business.exam.studentquest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.yincheng.oes.business.exam.studentquest.entity.StudentQuestion;
import com.yincheng.oes.business.exam.studentquest.service.StudentQuestionService;
import com.yincheng.oes.business.util.dictionary.DictionaryService;

/**
 * @author yangsy
 * @version 1.0.0
 * @since
 * 创建时间：2018年9月14日
 * <p>
 * 功能描述：
 * <p>
 * 邮箱地址：446948434@qq.com
 */
@Controller
@RequestMapping("/studentQuestion")
public class StudentQuestionController {

    @Autowired
    private DictionaryService dictionaryService;

    @Autowired
    private StudentQuestionService studentQuestionService;

    /**
     * 问题提交页面
     *
     * @param view
     * @return
     */
    @RequestMapping(value = "/createPage.html", method = RequestMethod.GET)
    public ModelAndView createPage(ModelAndView view) {
        view.addObject("bookClasses", dictionaryService.getByModel("book_class"));
        view.setViewName("/business/studentquest/quest-edit");
        return view;
    }

    @RequestMapping(value = "/submitQuestions.json", method = RequestMethod.POST)
    public void submitQuestions(@RequestBody List<StudentQuestion> questions) {
        studentQuestionService.createStudentQuestion(questions);
    }
}
